package com.wubotao.algorithm;

import java.util.Arrays;

public class SelectionSort {

	public static void sort(int[] array) {
		for (int i = 0; i < array.length; i++) {
			int min = i;
			for (int j = i + 1; j < array.length; j++) {
				if (array[j] < array[min]) {
					min = j;
				}
			}
			
			int temp = array[min];
			array[min] = array[i];
			array[i] = temp;
		}
	}

	public static void main(String[] args) {
		int[] array = new int[] { 1, 4, 45, 67, 12, 7682, 34, 23, 56 };
		sort(array);
		System.out.println(Arrays.toString(array));
	}
}


